home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / cli / mx2src.arc / REDIR.MOD < prev    next >
Text File  |  1989-01-05  |  3KB  |  94 lines

  1.  
  2. (*              Copyright 1987 fred brooks LogicTek             *)
  3. (*                                                              *)
  4. (*                                                              *)
  5. (*   First Release                      12/8/87-FGB             *)
  6. (*                                                              *)
  7.  
  8. MODULE redir;
  9. (*$T- *)
  10. FROM SYSTEM IMPORT ADDRESS, CODE, REGISTER, SETREG;
  11. FROM GEMX   IMPORT BasePageAddress, BasePageType ;
  12. FROM GEMDOS IMPORT TermRes;
  13. FROM XBIOS  IMPORT SuperExec;
  14. VAR         cmd,dev,a7,sr,port,oldbios  :       ADDRESS;
  15.             bios [0b4H]                 :       ADDRESS;
  16.             aline [28H]                 :       ADDRESS;
  17.             gem   [88H]                 :       ADDRESS;
  18.             char                        :       CHAR;
  19.  
  20. (*$P-,$S- *)
  21. PROCEDURE       changedevbios;
  22. BEGIN
  23.         CODE(48e7H,0fffeH);     (* save regs *)
  24.         CODE(306fH,60);         (* move.w 60(a7),a0  get sr *)
  25.         sr:=REGISTER(8);
  26.         IF sr<3ffH THEN        (* called from user mode *)
  27.            CODE(204fH);            (* move.l a7,a0 *)
  28.            a7:=REGISTER(8);        (* save ssp *)
  29.            CODE(4e68H,2e48H);      (* move.l usp,a0  move.l a0,a7 *)
  30.            CODE(306fH,2);  (* move.w 2(a7),a0 *)
  31.            dev:=REGISTER(8);
  32.            CODE(306fH,0);  (* move.w 0(a7),a0 *)
  33.            cmd:=REGISTER(8);
  34.            IF (cmd=1) OR (cmd=2) OR (cmd=3) OR (cmd=8) THEN
  35.               IF dev=2 THEN
  36.                  dev:=port; (* change to port *)
  37.                  SETREG(8,dev);
  38.                  CODE(3f48H,2); (* move.w a0,2(a7) set value in stack *)
  39.               END;
  40.            END;
  41.            SETREG(8,a7);
  42.            CODE(2e48H);            (* move.l a0,a7 *)
  43.         ELSE                       (* called from super mode *)
  44.            CODE(306fH,68);  (* move.w 68(a7),a0 *)
  45.            dev:=REGISTER(8);
  46.            CODE(306fH,66);  (* move.w 66(a7),a0 *)
  47.            cmd:=REGISTER(8);
  48.            IF (cmd=1) OR (cmd=2) OR (cmd=3) OR (cmd=8) THEN
  49.               IF dev=2 THEN
  50.                  dev:=port; (* change to port *)
  51.                  SETREG(8,dev);
  52.                  CODE(3f48H,68); (* move.w a0,68(a7) set value in stack *)
  53.               END;
  54.            END;
  55.         END;
  56.         SETREG(8,oldbios);  (* move trap adr *)
  57.         CODE(43faH,10); (* lea 12(pc),a1 *)
  58.         CODE(2288H); (* move.l a0,(a1) *)
  59.         CODE(4cdfH,7fffH); (* restore regs movem *)
  60.         CODE(4ef9H,0,0) (* jmp back to routine *)
  61. END             changedevbios;
  62. (*$P+,$S+ *)
  63.         
  64. (*$P-,$S- *)
  65. PROCEDURE       dummyvector;
  66. BEGIN
  67.         CODE(4e73H); (* rte *)
  68. END             dummyvector;
  69. (*$P+,$S+ *)
  70.         
  71. (*$P-,$S- *)
  72. PROCEDURE       setup;
  73. BEGIN
  74.         oldbios:=bios;
  75.         bios:=ADDRESS(changedevbios);
  76. (*        aline:=ADDRESS(dummyvector); *)
  77.         gem:=ADDRESS(dummyvector);
  78.         CODE(4e75H);    (* RTS *)
  79. END             setup;
  80. (*$P+,$S+ *)
  81.         
  82. BEGIN;
  83.     char:=BasePageAddress^.CmdLine[1];
  84.     IF (char='m') OR (char='M') THEN
  85.        port:=3;   (* midi *)
  86.     ELSE
  87.        port:=1;   (* aux  *)
  88.     END;
  89.     SuperExec(setup);
  90.     WITH BasePageAddress^ DO
  91.     TermRes(CodeLen+BssLen+LONGCARD(CodeBase-ADDRESS(BasePageAddress)),0);
  92.     END;
  93. END redir.
  94.